package com.investmenttechnologyservices.util;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.tools.mapreduce.Mapper;

public class SumMapper extends Mapper<Entity, String, Double> {
	private static final long serialVersionUID = 1779281109077447827L;
	private String sumOf;
	private String sumBy;
	public SumMapper(String sumOf, String sumBy) {
		this.sumOf = sumOf;
		this.sumBy = sumBy;
	}
	@Override
	public void map(Entity entity) {
		Double sumOfValue = (Double)entity.getProperty(this.sumOf);
		String sumByValue = (String)entity.getProperty(this.sumBy);
		getContext().emit(sumByValue, sumOfValue);
	}
}
